package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.pojo.User;
import com.bwie.service.UserService;
import com.bwie.mapper.UserMapper;
import com.bwie.utils.R;
import com.bwie.vo.UserVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
* @author 61630
* @description 针对表【tb_user】的数据库操作Service实现
* @createDate 2024-07-19 08:50:15
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>implements UserService{
    @Resource
    private UserMapper userMapper;
    @Override
    public R getLogin(UserVo userVo) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(User::getUserName,userVo.getUserName());
        User user = userMapper.selectOne(wrapper);
        if(Objects.isNull(user)){
            return R.error("账号错误");
        }
        if(!user.getPassword().equals(userVo.getPassword())){
            return R.error("密码错误");
        }
        return R.success("登录成功");
    }
}




